﻿#include<iostream>
#include<conio.h>
using namespace std;
struct Role {
	int Hp;
	int MaxHp;
	int Mp;
	int MaxMp;
	int act;
	int cantact;//禁止攻击
	int bufcount;//回合
	bool cant;
};
int main() {

	Role user{ 3000,3000,1000,1000,50,false };
	Role boss{ 30000,30000,1000,1000,190,false };
	int inKey, damage{};

	int* pUserHp = &user.Hp;
	int* pBossHp = &boss.Hp;

	int* pUserMaxHp = &user.MaxHp;
	int* pBossMaxHp = &boss.MaxHp;

	int* pUserMp = &user.Mp;
	int* pUserMaxMp = &user.MaxMp;

	int* pUserAct = &user.act;

lfight:
	system("cls");
	printf("生命[ %d / %d ]         BOSS生命[ %d / %d ]\n", *pUserHp, *pUserMaxHp, *pBossHp, *pBossMaxHp);
	printf("内力[ %d / %d ]  攻击力[%d]", *pUserMp, *pUserMaxMp, *pUserAct);


	inKey = _getch();
	damage = 0;
	switch (inKey) {
	case 49:
		if (*pUserMp > 99) {
			*pUserMp -= 100;
			*pUserHp += 300;
			*pUserHp = *pUserHp > *pUserMaxHp ? *pUserMaxHp : *pUserHp;
		}
		break;

	case 50:
		if (*pUserMp >= 50) {
			*pUserMp -= 50;
			*pBossHp -= 50 + *pUserAct;
		}
		break;

	case 51:
		if (*pUserMp >= 50) {
			*pUserMp -= 50;
			user.cantact = 3;
		}
		break;

	case 52: {
		user.bufcount = 10;
	}
		   break;

	case 53:
		if (*pUserMp >= 100) {
			*pUserMp -= 100;
			damage = *pUserMaxHp - *pUserHp + *pUserAct;
		}
		break;

	case 54:
		if ((*pUserMp >= 300) && (!user.cant)) {
			int ls = *pUserMaxHp;
			*pUserMaxHp = *pUserMaxMp;
			*pUserMaxMp = ls;
			ls = *pUserHp;
			*pUserHp = *pUserMp;
			*pUserMp = ls;
			*pUserAct *= 10;
			user.cant = true;
		}
		break;
	}
	if (boss.cantact > 0) {
		boss.cantact--;
	}
	else pUserHp -= boss.act;

	pBossHp -= damage;
	if (user.bufcount > 0) {
		user.bufcount--;
		*pUserHp += damage * 0.6;
		*pUserMp += damage * 0.2;
		*pUserHp = *pUserHp > *pUserMaxHp ? *pUserMaxHp : *pUserHp;
		*pUserMp = *pUserMp > *pUserMaxMp ? *pUserMaxMp : *pUserMp;
	}

	if (*pUserHp < 1) {
		system("cls");
		cout << "游戏结束！";
	}
	else if (*pBossHp < 1) {
		system("cls");
		cout << "击败BOSS！";
	}
	else goto lfight;
}